<?php

namespace App\Models\Admin;

use App\Models\Model;

class AdminRole extends Model
{
    protected $table = 'admin_role';
    protected $primaryKey = 'role_id';

    //fillable 属性指定哪些属性可以被集体赋值;Guarded则相反
    protected $guarded = [];

    public function users()
    {
        return $this->belongsToMany('App\Models\Admin\AdminUsers', 'admin_users_role', 'role_id', 'user_id')
            ->using('App\Models\Admin\AdminUsersRole');
    }

    public function routes()
    {
        return $this->belongsToMany('App\Models\Admin\AdminRoute','admin_route_role','role_id', 'route_id')
            ->using('App\Models\Admin\AdminRouteRole');
    }

}
